package com.itheima02;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Test05 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

        ClassLoader loader = ClassLoader.getSystemClassLoader();

        InputStream stream = ClassLoader.getSystemResourceAsStream("a.properties");

        Properties properties = new Properties();

        properties.load(stream);

        String className = properties.getProperty("className");
        String methodName = properties.getProperty("methodName");

        Class clazz = Class.forName(className);

        Object obj = clazz.getDeclaredConstructor().newInstance();

        Method method = clazz.getDeclaredMethod(methodName);

        method.invoke(obj);

    }
}
